home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-03 | 4.4 KB | 153 lines | [TEXT/MPS ] |
- /*************************************************************************************
- *
- * Object Oriented Shell
- *
- * Main.cp - C Source File
- *
- * Copyright © Apple Computer, Inc. 1988 - 1993
- * All rights reserved.
- *
- * This file contains the initialization code for SortPicts.
- * It will call GWorldObj for the first time.
- * GWorldObj.InitObj will initialize any static (i.e. global variables) it uses.
- *
- *************************************************************************************/
-
- #include "WindowObj.Link"
- #include "main.h"
- #include "Traps.h"
-
-
- /**************************************************************************************
-
- The "g" prefix is used to emphasize that a variable is global.
-
- ***************************************************************************************/
-
- SysEnvRec gMac;
- Boolean gQuit;
- Boolean gInBackground;
-
- // the QDGlobals are very special.
- // 68K gives them to developers as the data structure just before
- // the Jump Table (theres a pointer at (A5) that points to QD Globals
- // PPC, on the other hand, doesn't have those, so you need to allocate them
- #ifdef __powerc
- QDGlobals qd;
- #endif
-
-
- /**************************************************************************************
-
- main
-
- Entry point for our program. We initialize the Toolbox, make sure we are
- running on a sufficiently brawny machine, and put up the menu bar. Finally,
- we start polling for events and handling them by entering our main event
- loop.
-
- ***************************************************************************************/
- int main()
- {
- /* If you have stack requirements that differ from the default,
- then you could use SetApplLimit to increase StackSpace at
- this point, before calling MaxApplZone. */
-
- MaxApplZone(); /* Expand the heap so code segments load at the top */
- initToolbox(); /* Initialize the program */
- MainEventLoop(); /* Call the real program which does the stuff! */
- return 0;
- }
-
- /**************************************************************************************
-
- InitToolbox
-
- Set up the whole world, including global variables, Toolbox managers, and menus.
-
- ***************************************************************************************/
- void initToolbox( void)
- {
- Handle menuBar;
- EventRecord event;
- short count;
- WINDOWOBJ *tempWindowObj;
- long threadsPresentBit;
-
-
- gInBackground = false;
- gQuit = false;
-
- InitGraf( (Ptr) &qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NIL);
- InitCursor();
-
- /* This next bit of code waits until multi-finder brings our application
- to the front. This gives us a better effect if we open a window at
- startup. */
-
- for( count = 1; count <= 3; ++count)
- EventAvail(everyEvent, &event);
-
- SysEnvirons(curSysEnvVers, &gMac);
-
- if( gMac.machineType < 0)
- DeathAlert( errWimpyROMs);
- if( gMac.processor < env68020)
- DeathAlert( errWimpy68K);
- if( gMac.systemVersion < 0x0700)
- DeathAlert( errWimpySystem);
- if( gMac.hasColorQD == false)
- DeathAlert( errWimpyQD);
-
- if( Gestalt( gestaltThreadMgrAttr, &threadsPresentBit) != noErr)
- DeathAlert(errNoThreads);
-
- if( ((1<<gestaltThreadMgrPresent) & threadsPresentBit) == 0)
- DeathAlert(errNoThreads);
-
- menuBar = GetNewMBar( rMenuBar); /* Read menus into menu bar */
- if( menuBar == NIL)
- DeathAlert( errNoMenuBar);
- SetMenuBar( menuBar); /* Install our menus */
- DisposHandle(menuBar);
- AddResMenu(GetMHandle(mApple), 'DRVR'); /* Add DA names to Apple menu */
-
- AppAdjustMenus();
- DrawMenuBar();
-
- tempWindowObj = new WINDOWOBJ; /* Object window support */
- tempWindowObj->InitObj(); /* This performs initialization */
- delete tempWindowObj;
-
- }
-
- /**************************************************************************************
-
- DeathAlert
-
- Display an alert that tells the user an error occurred, then exit the
- program. This routine is used as an ultimate bail-0out for serious errors
- that bprohibit the continuation of the application. The error number is
- used to index an STR# resource so that a relevant message can be displayed.
-
- ***************************************************************************************/
- void DeathAlert(short errNumber)
- {
- short itemHit;
- Str255 theMessage;
-
- SetCursor( &qd.arrow);
- GetIndString(theMessage, rErrorStrings, errNumber);
- ParamText(theMessage, NIL, NIL, NIL);
- SetCursor( &qd.arrow);
- itemHit = StopAlert(rErrorAlert, NIL);
- ExitToShell();
- }
-
-
-